// src/store/index.js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        formData: {
            step1: {
                line: '',
                station: '',
                roomType: '',
                rentType: '',
                balcony: '',
                rent: '',
                term: '',
                payType: '',
                environment: '',
                introduction: ''
            },
            step2: {
                wechat: '',
                phone: '',
                moveInDate: '',
                validUntil: '',
                title: ''
            },
            sublet1: {
                longitude: '',
                latitude: '',
                location: '',
                imagesUrl: '',
                videoUrl: '',
                nearbyStation: '',
                structure: '',
                male: 0,
                female: 0
            },
            sublet2: {
                introduce: '',
                rent: null,
                tenancyTerm: 3,
                payType: '押一付一',
                renterRequire: '',
                landlord: '',
                contractExpiration: '',
                moveTime: ''
            },
            sublet3: {
                wechat: '',
                phone: '',
                visitingTime: '最好午休、下班以后和周末',
                endTime: '',
                title: ''
            },
            rental1:{
                longitude: '',
                latitude: '',
                location: '',
                imagesUrl: '',
                videoUrl: '',
                nearbyStation: '',
                structure: '',
                introduce: '',
                rent: '',
                tenancyTerm: '',
                payType: ''
            },
            rental2:{
                renterRequire: '',
                landlord:'',
                contractExpiration: '',
                moveTime: '',
                visitingTime: '',
                wechat: '',
                phone: ''
            },
            rental3:{
                endTime: '',
                title: ''
            }
        }
    },
    mutations: {
        SET_STEP1_DATA(state, data) {
            state.formData.step1 = {...state.formData.step1, ...data}
        },
        SET_STEP2_DATA(state, data) {
            state.formData.step2 = {...state.formData.step2, ...data}
        },
        SET_SUBLET1_DATA(state, data) {
            state.formData.sublet1 = {...state.formData.sublet1,...data}
        },
        SET_SUBLET2_DATA(state, data) {
            state.formData.sublet2 = {...state.formData.sublet2,...data}
        },
        SET_SUBLET3_DATA(state, data) {
            state.formData.sublet3 = {...state.formData.sublet3,...data}
        },
        SET_RENTAL1_DATA(state,data) {
            state.formData.rental1 = {...state.formData.rental1,...data}
        },
        SET_RENTAL2_DATA(state,data) {
            state.formData.rental2 = {...state.formData.rental2,...data}
        },
        SET_RENTAL3_DATA(state,data) {
            state.formData.rental3 = {...state.formData.rental3,...data}
        },
    }
})

export default store
